home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / bfd / doc / section.p < prev    next >
Encoding:
Text File  |  1991-09-29  |  8.1 KB  |  399 lines

  1. /* The shape of a section struct:
  2. */
  3.  
  4. typedef struct sec {
  5.  
  6. /*
  7. The name of the section, the name isn't a copy, the pointer is
  8. the same as that passed to bfd_make_section.
  9. */
  10.  
  11.     CONST char *name;
  12.  
  13. /*
  14. The next section in the list belonging to the BFD, or NULL.
  15. */
  16.  
  17.     struct sec *next;
  18.  
  19. /*
  20. The field flags contains attributes of the section. Some of these
  21. flags are read in from the object file, and some are synthesized from
  22. other information. 
  23. */
  24.  
  25. flagword flags;
  26.  
  27. /*
  28. */
  29.  
  30. #define SEC_NO_FLAGS   0x000
  31.  
  32. /*
  33. Tells the OS to allocate space for this section when loaded.
  34. This would clear for a section containing debug information only.
  35. */
  36.  
  37. #define SEC_ALLOC      0x001
  38.  
  39. /*
  40. Tells the OS to load the section from the file when loading.
  41. This would be clear for a .bss section 
  42. */
  43.  
  44. #define SEC_LOAD       0x002
  45.  
  46. /*
  47. The section contains data still to be relocated, so there will be some
  48. relocation information too.
  49. */
  50.  
  51. #define SEC_RELOC      0x004
  52.  
  53. /*
  54. Obsolete ? 
  55. */
  56.  
  57. #define SEC_BALIGN     0x008
  58.  
  59. /*
  60. A signal to the OS that the section contains read only data.
  61. */
  62.  
  63. #define SEC_READONLY   0x010
  64.  
  65. /*
  66. The section contains code only.
  67. */
  68.  
  69. #define SEC_CODE       0x020
  70.  
  71. /*
  72. The section contains data only.
  73. */
  74.  
  75. #define SEC_DATA        0x040
  76.  
  77. /*
  78. The section will reside in ROM.
  79. */
  80.  
  81. #define SEC_ROM        0x080
  82.  
  83. /*
  84. The section contains constructor information. This section type is
  85. used by the linker to create lists of constructors and destructors
  86. used by @code{g++}. When a back end sees a symbol which should be used
  87. in a constructor list, it creates a new section for the type of name
  88. (eg @code{__CTOR_LIST__}), attaches the symbol to it and builds a
  89. relocation. To build the lists of constructors, all the linker has to
  90. to is catenate all the sections called @code{__CTOR_LIST__} and
  91. relocte the data contained within - exactly the operations it would
  92. peform on standard data.
  93. */
  94.  
  95. #define SEC_CONSTRUCTOR 0x100
  96.  
  97. /*
  98. The section is a constuctor, and should be placed at the end of the ..
  99. */
  100.  
  101. #define SEC_CONSTRUCTOR_TEXT 0x1100
  102.  
  103. /*
  104. */
  105. #define SEC_CONSTRUCTOR_DATA 0x2100
  106.  
  107. /*
  108. */
  109. #define SEC_CONSTRUCTOR_BSS  0x3100
  110.  
  111. /*
  112.  
  113. The section has contents - a bss section could be
  114. @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}, a debug section could be
  115. @code{SEC_HAS_CONTENTS}
  116. */
  117.  
  118. #define SEC_HAS_CONTENTS 0x200
  119.  
  120. /*
  121. An instruction to the linker not to output sections containing
  122. this flag even if they have information which would normally be written.
  123. */
  124.  
  125. #define SEC_NEVER_LOAD 0x400
  126.  
  127. /*
  128.  
  129. The base address of the section in the address space of the target.
  130. */
  131.  
  132.    bfd_vma vma;
  133.  
  134. /*
  135. The size of the section in bytes of the loaded section. This contains
  136. a value even if the section has no contents (eg, the size of @code{.bss}).
  137. */
  138.  
  139.    bfd_size_type size;    
  140.  
  141. /*
  142. If this section is going to be output, then this value is the
  143. offset into the output section of the first byte in the input
  144. section. Eg, if this was going to start at the 100th byte in the
  145. output section, this value would be 100. 
  146. */
  147.  
  148.    bfd_vma output_offset;
  149.  
  150. /*
  151. The output section through which to map on output.
  152. */
  153.  
  154.    struct sec *output_section;
  155.  
  156. /*
  157. The alignment requirement of the section, as an exponent - eg 3
  158. aligns to 2^3 (or 8) 
  159. */
  160.  
  161.    unsigned int alignment_power;
  162.  
  163. /*
  164. If an input section, a pointer to a vector of relocation records for
  165. the data in this section.
  166. */
  167.  
  168.    struct reloc_cache_entry *relocation;
  169.  
  170. /*
  171. If an output section, a pointer to a vector of pointers to
  172. relocation records for the data in this section.
  173. */
  174.  
  175.    struct reloc_cache_entry **orelocation;
  176.  
  177. /*
  178. The number of relocation records in one of the above 
  179. */
  180.  
  181.    unsigned reloc_count;
  182.  
  183. /*
  184. Which section is it 0..nth     
  185. */
  186.  
  187.    int index;                      
  188.  
  189. /*
  190. Information below is back end specific - and not always used or
  191. updated 
  192.  
  193. File position of section data   
  194. */
  195.  
  196.    file_ptr filepos;      
  197. /* File position of relocation info        
  198. */
  199.  
  200.    file_ptr rel_filepos;
  201.  
  202. /*
  203. File position of line data              
  204. */
  205.  
  206.    file_ptr line_filepos;
  207.  
  208. /*
  209. Pointer to data for applications        
  210. */
  211.  
  212.    PTR userdata;
  213.  
  214. /*
  215. */
  216.    struct lang_output_section *otheruserdata;
  217.  
  218. /*
  219. Attached line number information        
  220. */
  221.  
  222.    alent *lineno;
  223. /* Number of line number records   
  224. */
  225.  
  226.    unsigned int lineno_count;
  227.  
  228. /*
  229. When a section is being output, this value changes as more
  230. linenumbers are written out 
  231. */
  232.  
  233.    file_ptr moving_line_filepos;
  234.  
  235. /*
  236. what the section number is in the target world 
  237. */
  238.  
  239.    unsigned int target_index;
  240.  
  241. /*
  242. */
  243.    PTR used_by_bfd;
  244.  
  245. /*
  246. If this is a constructor section then here is a list of the
  247. relocations created to relocate items within it.
  248. */
  249.  
  250.    struct relent_chain *constructor_chain;
  251.  
  252. /*
  253. The BFD which owns the section.
  254. */
  255.  
  256.    bfd *owner;
  257.  
  258. /*
  259. */
  260. } asection ;
  261.  
  262. /*
  263.  
  264.  bfd_get_section_by_name
  265. Runs through the provided @var{abfd} and returns the @code{asection}
  266. who's name matches that provided, otherwise NULL. @xref{Sections}, for more information.
  267. */
  268.  
  269.  PROTO(asection *, bfd_get_section_by_name,
  270.     (bfd *abfd, CONST char *name));
  271.  
  272. /*
  273.  
  274.  bfd_make_section
  275. This function creates a new empty section called @var{name} and attaches it
  276. to the end of the chain of sections for the BFD supplied. An attempt to
  277. create a section with a name which is already in use, returns the old
  278. section by that name instead.
  279.  
  280. Possible errors are:
  281. @table @code
  282. @item invalid_operation
  283. If output has already started for this BFD.
  284. @item no_memory
  285. If obstack alloc fails.
  286. @end table
  287. */
  288.  
  289.  PROTO(asection *, bfd_make_section, (bfd *, CONST char *name));
  290.  
  291. /*
  292.  
  293.  bfd_set_section_flags
  294. Attempts to set the attributes of the section named in the BFD
  295. supplied to the value. Returns true on success, false on error.
  296. Possible error returns are:
  297. @table @code
  298. @item invalid operation
  299. The section cannot have one or more of the attributes requested. For
  300. example, a .bss section in @code{a.out} may not have the
  301. @code{SEC_HAS_CONTENTS} field set.
  302. @end table
  303. */
  304.  
  305.  PROTO(boolean, bfd_set_section_flags,
  306.        (bfd *, asection *, flagword));
  307.  
  308. /*
  309.  
  310.  bfd_map_over_sections
  311. Calls the provided function @var{func} for each section attached to
  312. the BFD @var{abfd}, passing @var{obj} as an argument. The function
  313. will be called as if by 
  314.  
  315. @example
  316.   func(abfd, the_section, obj);
  317. @end example
  318. */
  319.  
  320.  PROTO(void, bfd_map_over_sections,
  321.             (bfd *abfd, void (*func)(), PTR obj));
  322.  
  323. /*
  324.  
  325. This is the prefered method for iterating over sections, an
  326. alternative would be to use a loop:
  327.  
  328. @example
  329.    section *p;
  330.    for (p = abfd->sections; p != NULL; p = p->next)
  331.       func(abfd, p, ...)
  332. @end example
  333.  
  334.  bfd_set_section_size
  335. Sets @var{section} to the size @var{val}. If the operation is ok, then
  336. @code{true} is returned, else @code{false}. 
  337.  
  338. Possible error returns:
  339. @table @code
  340. @item invalid_operation
  341. Writing has started to the BFD, so setting the size is invalid
  342. @end table 
  343. */
  344.  
  345.  PROTO(boolean, bfd_set_section_size,
  346.      (bfd *, asection *, bfd_size_type val));
  347.  
  348. /*
  349.  
  350.  bfd_set_section_contents
  351. Sets the contents of the section @var{section} in BFD @var{abfd} to
  352. the data starting in memory at @var{data}. The data is written to the
  353. output section starting at offset @var{offset} for @var{count} bytes.
  354.  
  355. Normally @code{true} is returned, else @code{false}. Possible error
  356. returns are:
  357. @table @code
  358. @item no_contents
  359. The output section does not have the @code{SEC_HAS_CONTENTS}
  360. attribute, so nothing can be written to it.
  361. @item and some more too
  362. @end table
  363. This routine is front end to the back end function @code{_bfd_set_section_contents}.
  364. */
  365.  
  366.  PROTO(boolean, bfd_set_section_contents,
  367.          (bfd *abfd,        
  368.          asection *section,
  369.          PTR data,
  370.          file_ptr offset,
  371.          bfd_size_type count));
  372.  
  373. /*
  374.  
  375.  bfd_get_section_contents
  376. This function reads data from @var{section} in BFD @var{abfd} into
  377. memory starting at @var{location}. The data is read at an offset of
  378. @var{offset} from the start of the input section, and is read for
  379. @var{count} bytes.
  380.  
  381. If the contents of a constuctor with the @code{SEC_CONSTUCTOR} flag
  382. set are requested, then the @var{location} is filled with zeroes.
  383.  
  384. If no errors occur, @code{true} is returned, else @code{false}.
  385. Possible errors are:
  386.  
  387. @table @code
  388. @item unknown yet
  389. @end table
  390. */
  391.  
  392.  PROTO(boolean, bfd_get_section_contents, 
  393.         (bfd *abfd, asection *section, PTR location,
  394.          file_ptr offset, bfd_size_type count));
  395.  
  396. /*
  397. */
  398.  
  399.